
/**Created by the LayaAirIDE*/
module view.dlg{
	export class ShieldInvite extends ui.dlg.ShieldInviteUI{
		constructor(){
			super();

            this.btnClose.on(Laya.Event.CLICK, this, this.Close);
            this.btnOpen.on(Laya.Event.CLICK, this, this.OnBtnOpenClick);
            this.btnInvite.on(Laya.Event.CLICK, this, this.OnBtnInviteClick);
		}

        Close() {
			this.close();
		}

        ShowInvite() {
            if (ShieldModel.GetIsOpen() != 0) {
                return;
            }
            let inviteList = ShieldModel.GetInviteList();
            if (inviteList.length < Cfg.CommonCfg["shieldInviteNum"]) {
                this.btnOpen.visible = false;
                this.btnInvite.visible = true;
                
            } else {
                this.btnOpen.visible = true;
                this.btnInvite.visible = false;
                if (inviteList.length > 0) {
                    this.imgHead.loadImage(inviteList[0].avatarUrl, 0, 0, 100, 100);
                }
            }
            this.popup();
        }

        //激活护盾
        OnBtnOpenClick() {
            ComFun.BaseCall("openShield");
            this.close();
        }

        //邀请
        OnBtnInviteClick() {
            CtrlManager.GetCtrl(CtrlNames.Share).shareSpecify(Cfg.ShareCfg["share_type_shield"]["value"]);
        }
	}
}